-- hide_shelf
-- 洞窟里奇怪的书架
-- create by huanghr

return {
    apply = function(source, target, classId, value)
        local shelfBonus = ME.user.dbase:query("hide_shelf_bonus") or {};

        local rand = DungeonM.getRandSeed("hide_shelf_bonus");
        local amount;
        local arr;

        if type(shelfBonus[3]) == "string" then
            -- 随机范围奖励
            arr = string.explode(shelfBonus[3], "~");
            amount = tonumber(arr[1]) + rand % tonumber(arr[2] - arr[1] + 1);
        else
            amount = shelfBonus[3];
        end

        -- 随机奖励
        local bonus = { shelfBonus[1], shelfBonus[2], amount};

        BonusM.doBonus(bonus, "cave_hide_shelf");

        ME.user.dbase:delete("hide_shelf_bonus");

        -- 抛出播放特效事件
        -- EventMgr.fire(event.GAIN_RANDOM_BONUS, { ["bonus"] = bonus } );
    end,
};
